<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>供应商管理系统-{$webname}</title>
    {Common::css("style.css,base.css,extend.css,supplier_back.css")}
    {Common::css("v1/base.css,v1/admin.css")}
    {Common::js("jquery.min.js,common.js,city/jquery.cityselect.js,layer/layer.js")}
</head>
<body>
    <div class="supplier-main-block">
        <div class="account-box">
            <div class="main-content">
                <div class="info-view-block pd-20">
                    <form id="usrfrm">
                        <ul class="info-view-group">
                            <li>
                                <div class="info-hd">LOGO：</div>
                                <div class="info-bd my_header">
                                    <input type="file" class="litpic_upload" id="litpic_upload"/>
                                    <div class="cl mt-10">
                                        <div class="upload-img-area">
                                            {if !empty($userinfo['litpic'])}
                                            <img id="face" src="{$userinfo['litpic']}" width="94" height="94"/>
                                            <input type="hidden" class="show_header" name="litpic" value="{$userinfo['litpic']}"/>
                                            {else}
                                            <img id="face" src="{$GLOBALS['cfg_res_url']}/images/default-headimg.jpg" width="94" height="94"/>
                                            {/if}
                                        </div>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="info-hd">姓名：</div>
                                <div class="info-bd">
                                    <input type="text" name="linkman" value="{$userinfo['linkman']}" class="input-text w200"/>
                                </div>
                            </li>
                            <li>
                                <div class="info-hd">手机号码：</div>
                                <div class="info-bd">
                                    <span class="item-text">{$userinfo['mobile']}</span>
                                    <div class="cl">
                                        <a name="更换手机" href="{$cmsurl}pc/user/modify_phone" class="btn btn-primary radius size-MINI va-t mt-3">{if empty($userinfo['mobile'])}绑定{else}更换{/if}手机</a>
                                    </div>
                                </div>

                            </li>
                            {if St_Functions::is_normal_app_install('zlhl_verify_order') || St_Functions::is_normal_app_install('zlhlorder') || St_Functions::is_normal_app_install('zlhlhotel')}
                            <li>
                                <div class="info-hd">智旅互联：</div>
                                <div class="info-bd">
                                    {if !$is_bind}
                                    <span class="item-text">未绑定</span>
                                    {else}
                                    <span class="item-text">已绑定</span>
                                    {/if}
                                    <div class="cl">
                                        {if $is_bind}
                                        <button name="解绑账号" class="btn btn-primary radius size-MINI va-t mt-3 ml-5" id="unbind_zlhl" type="button">解绑账号</button>
                                        {else}
                                        <button name="绑定账号" class="btn btn-primary radius size-MINI va-t mt-3" id="bind_zlhl" type="button">绑定账号</button>
                                        {/if}
                                        <span class="item-text c-999 ml-10">*绑定账号后，您可以使用智旅互联APP及时接受订单消息 <a href="http://www.stourweb.com/help/show/1144.html" style="color:#14c377" target="_blank">帮助指引</a></span>
                                    </div>
                                </div>
                            </li>
                            {/if}
                            <li>
                                <div class="info-hd">电子邮箱：</div>
                                <div class="info-bd">
                                    <span class="item-text">{$userinfo['email']}</span>
                                    <div class="cl">
                                        <a href="{$cmsurl}pc/user/modify_email" class="btn btn-primary radius size-MINI va-t mt-3">{if empty($userinfo['email'])}绑定{else}更换{/if}邮件</a>
                                    </div>
                                </div>
                            </li>
                            <li>
                                <div class="info-hd">客服QQ：</div>
                                <div class="info-bd">
                                    <input type="text" class="input-text w200" name="qq" value="{$userinfo['qq']}"/>
                                </div>
                            </li>
                            <li>
                                <div class="info-hd">客服电话：</div>
                                <div class="info-bd">
                                    <input type="text" class="input-text w200" name="telephone" value="{$userinfo['telephone']}"/>
                                </div>
                            </li>
                            <li>
                                <div class="info-hd">传真：</div>
                                <div class="info-bd">
                                    <input type="text" class="input-text w200" name="fax" value="{$userinfo['fax']}"/>
                                </div>
                            </li>
                        </ul>
                        <div class="cl mt-20 pl-105">
                            <a href="javascript:;" name="保存" class="btn btn-primary radius size-L save_btn">保存</a>
                        </div>
                        <input type="hidden" id="supplierid" name="supplierid" value="{$userinfo['id']}">
                        <input type="hidden" id="frmcode" name="frmcode" value="{$frmcode}"/>
                    </form>
                </div>
            </div>
        </div>

        <div class="create-company mr-40" style="display: none">
            <ul class="info-view-group">
                <li>
                    <span class="info-hd">账号：</span>
                    <div class="info-bd">
                        <input type="text" class="input-text  zlhl_account" placeholder="请输入智旅互联账号">
                    </div>
                </li>
                <li>
                    <span class="info-hd">密码：</span>
                    <div class="info-bd">
                        <input type="password" class="input-text zlhl_password" placeholder="请输入智旅互联密码">
                    </div>
                </li>
                <li>
                    <span class="info-bd">没有账号，
                        <a class="lk" href="http://member.stourweb.cn/member/register" target="_blank">马上注册</a>
                        <a class="lk" href="http://member.stourweb.cn/member/register/findpass">找回密码</a>
                    </span>
                </li>
            </ul>

        </div>
        <!-- 创建企业 -->
    </div>
    <script>
        var SITEURL = "<?php echo $cmsurl;?>";
    </script>
    <script>

        $(function () {
            $("#nav_userinfo").addClass('on');


            //上传头像点击
            $(".litpic_upload").change(function () {
                var ziduan = $(this).attr("id");
                var file = document.getElementById(ziduan);
                var fileList = file.files; //获取的图片文件
                if (fileList.length > 1) {
                    alert("只能上传一张图");
                    return;  //一次选择上传超过5个 或者是已经上传和这次上传的到的总数也不可以超过5个
                }
                for (var i = 0; i < fileList.length; i++) {
                    var imgUrl = window.URL.createObjectURL(fileList[i]);
                    $('#face').attr('src', imgUrl);
                    //ajax上传到服务器
                    var formData = new FormData();
                    formData.append('Filedata', $(this)[0].files[0]);  //添加图片信息的参数
                    //formData.append('sizeid',123);  //添加其他参数
                    $.ajax({
                        url: SITEURL + 'pc/index/ajax_uploadface',
                        type: 'POST',
                        cache: false, //上传文件不需要缓存
                        data: formData,
                        dataType: 'json',
                        processData: false, // 告诉jQuery不要去处理发送的数据
                        contentType: false, // 告诉jQuery不要去设置Content-Type请求头
                        timeout: 3000,
                        success: function (rs) {
                            if (rs.status) {
                                var fileurl = rs.litpic;
                                var $input = $("<input id='litpic' name='litpic' value='" + fileurl + "' type='hidden'>");
                                $('.show_header').remove();
                                $('.my_header').append($input);
                            }
                        },
                        error: function (data) {
                            console.log(data)
                        }
                    })
                }
            });

            //智旅互联绑定
            $("#bind_zlhl").click(function () {
                //账号绑定
                layer.open({
                    type: 1,
                    title: '账号绑定',
                    area: ['400px', 'auto'],
                    btn: ['保存'],
                    content: $('.create-company'),
                    btnAlign: 'c',
                    yes: function (a) {//成功回调
                        var account = $(".layui-layer .zlhl_account").val();
                        var password = $(".layui-layer .zlhl_password").val();
                        $.ajax({
                            type: 'post',
                            url: SITEURL + 'pc/index/ajax_zlhl_bind',
                            data: {account: account, password: password},
                            dataType: 'json',
                            success: function (data) {
                                if (data.status) {
                                    layer.msg("{__('保存成功')}", {
                                        icon: 6,
                                        time: 1000
                                    })
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 1000);
                                } else {
                                    layer.msg(data.msg, {icon: 5});
                                    return false;
                                }
                            }
                        });
                        layer.close(a);
                    }

                });

            });

            $("#unbind_zlhl").click(function () {
                //账号绑定
                layer.open({
                    type: 1,
                    title: '账号',
                    area: ['400px', 'auto'],
                    btn: ['保存', '取消'],
                    btnAlign: 'c',
                    content: '<div class="include-company mr-40"><div class="ml-40 pt-20">是否解除绑定</div></div>',
                    yes: function (a) {
                        $.ajax({
                            type: 'post',
                            url: SITEURL + 'pc/index/ajax_zlhl_unbind',
                            dataType: 'json',
                            success: function (data) {
                                layer.close(a);
                                window.location.reload();
                            }
                        });

                    }
                });

            });


            //保存资料
            $(".save_btn").click(function () {
                var frmdata = $("#usrfrm").serialize();

                $.ajax({
                    type: 'post',
                    url: SITEURL + 'pc/index/ajax_userinfo_save',
                    data: frmdata,
                    dataType: 'json',
                    success: function (data) {
                        if (data.status) {
                            layer.msg("{__('保存成功')}", {
                                icon: 6,
                                time: 1000
                            })

                        } else {
                            layer.msg(data.msg, {icon: 5});
                            return false;
                        }
                    }
                })


            })
        })
    </script>
</body>
</html>
